import React, {PropTypes} from 'react';
import {Form, Input, Card, Row, Col, Button} from 'antd';
import {connect} from 'dva';
import styles from './LoginPage.less';

import Login from '../components/Auth/Login';
function LoginPage({dispatch, login}) {
    const {showError} = login;
    const loginProps = {
        showError,
        onSubmit(data) {
            dispatch({
                type: 'login/login',
                payload: data,
            });
        }
    };
    return (
        <div className={styles.normal}>
            <Row>
                <Col span={12} offset={6}>
                    <Card title="antd--admin管理系統" bordered={false} className={styles.my_card_header}
                          bodyStyle={{background: '#fff', color: '#333'}}>
                        <div style={{display: showError ? 'block' : 'none'}} className={styles.my_errornote}>
                            请输入一个正确的用户名 和密码
                        </div>
                        <Login  {...loginProps}/>
                    </Card>
                </Col>
            </Row>
        </div>
    );
}

LoginPage.propTypes = {
    login: PropTypes.object,
    dispatch: PropTypes.func
};
function mapStateToProps({login}) {
    return {login};
}
export default connect(mapStateToProps)(LoginPage);
